package com.cn.product.service;

import com.cn.api.ScenicCoreService;
import com.cn.common.parameter.Paging;
import com.cn.dto.ScenicDTO;
import com.cn.product.entity.Scenic;
import com.cn.product.mapper.ProductMapper;
import com.cn.product.mapper.ScenicMapper;
import com.netflix.discovery.converters.Auto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;

/**
 * @Description: ScenicCoreServiceImpl
 * @Author: ZhangMao
 * @Date: 2022-03-08
 * 景区服务
 * 原子层API的实现类
 */

@RestController
@RequestMapping("/scenic")
public class ScenicCoreServiceImpl implements ScenicCoreService {
    @Autowired
    private ScenicMapper scenicMapper;

    //查询所有景区
    @Override
    @GetMapping("/findAll")
    public List<ScenicDTO> findAll(Paging paging) {
        return null;
    }

    //根据id查询景区
    @Override
    @GetMapping("/findById")
    public ScenicDTO findById(Integer scenicId) {
        return null;
    }

    //添加景区
    @Override
    @PostMapping("/add")
    public int add(ScenicDTO scenicDTO) {
        Scenic scenic = new Scenic();
        int result = 0;

        scenic.setNames(scenicDTO.getNames());//景区名称
        scenic.setSorts(scenicDTO.getSorts());//景区分类id
        scenic.setIntroduces(scenicDTO.getIntroduces());//景区介绍
        scenic.setMaps(scenicDTO.getMaps());//景点分布图
        scenic.setServiceTime(scenicDTO.getServiceTime());//景区营业时间
        scenic.setDetails(scenicDTO.getDetails());//景区详情
        scenic.setGrade(scenicDTO.getGrade());//景区等级
        scenic.setLongitude(scenicDTO.getLongitude());//景区所在经度
        scenic.setLatitude(scenicDTO.getLatitude());//景区所在纬度
        scenic.setDetailAddress(scenicDTO.getDetailAddress());//景区详细地址
        scenic.setProvince(scenicDTO.getProvince());//景区所在省
        scenic.setCity(scenicDTO.getCity());//景区所在市
        scenic.setSuppliers(scenicDTO.getSuppliers());//供应商
        scenic.setNotification(scenicDTO.getNotification());//入园须知

        result = scenicMapper.add(scenic);
        return result;
    }

    //删除景区（逻辑删除）
    @PostMapping("/delete")
    public int delete(Integer scenicId) {

        return 1;
    }

    //修改景区信息
    @Override
    @PostMapping("/update")
    public int update(ScenicDTO scenicDTO) {
        return 1;
    }

    //根据条件查询景区
    @Override
    @GetMapping("/findCondition")
    public List<ScenicDTO> findCondition(ScenicDTO scenicDTO) {
        return null;
    }
}
